package com.zjy.software.day8;

public class SystemDemo {
    public static void main(String[] args)
    {
        System.out.println("当前时间："+System.currentTimeMillis());
        System.out.println("当前时间："+System.nanoTime());

        System.out.println("System.getProperty(\"java.home\") = " + System.getProperty("java.home"));


        //获取可用内存
        Runtime runtime = Runtime.getRuntime();
        long value = runtime.freeMemory();
        System.out.println("可用内存为:"+value/1024/1024+"mb");
        //获取jvm的总数量，该值会不断的变化
        long  totalMemory = runtime.totalMemory();
        System.out.println("全部内存为:"+totalMemory/1024/1024+"mb");
        //获取jvm 可以最大使用的内存数量，如果没有被限制 返回 Long.MAX_VALUE;
        long maxMemory = runtime.maxMemory();
        System.out.println("可用最大内存为:"+maxMemory/1024/1024+"mb");

        int cpuValue = runtime.availableProcessors(); //获取cpu执行数量
        System.out.println("cpuValue = " + cpuValue);
        //Process process = runtime.exec("calc"); //执行外部命令,在win下面执行
    }
}
